﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CnCNet
{
    public partial class cncNetMyGameForm : Form
    {
        public cncNetMyGameForm()
        {
            InitializeComponent();
        }

        public void refresh()
        {
            lock (cncNetForm.myGame)
            {
                if (this.tbxChat.Text != cncNetForm.myGame.chatlog)
                    tbxChat.Text = cncNetForm.myGame.chatlog;

                if (this.lbxPlayer.Items.Count != cncNetForm.myGame.players.Count)
                {
                    this.lbxPlayer.Items.Clear();
                    foreach (string player in cncNetForm.myGame.players)
                    {
                        this.lbxPlayer.Items.Add(player);
                    }
                }
            }
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            if (this.Visible)
            {
                e.Cancel = true;
                this.Hide();
            }
        }

        private void tmrRefresh_Tick(object sender, EventArgs e)
        {
            refresh();
        }
    }

}
